from sqlalchemy.orm import class_mapper


# SQLAlchemy对象转换为json字符串
def obj_to_json(obj):
    return dict((col.name, getattr(obj, col.name)) for col in class_mapper(obj.__class__).mapped_table.c)
